
# include "Socket.h"

Socket::Socket()
    : _impl()
{}

Socket::~Socket()
{}

Socket::Socket(Socket const & sock)
    : _impl(sock._impl)
{
}

Socket& Socket::operator=(Socket const & sock)
{
    if (this != &sock)
    {
        _impl = sock._impl;
    }
    return *this;
}

void Socket::open(int domain, int type)
{
    _impl.open(domain, type);
}

void Socket::bind(int port, char *addr)
{
    _impl.bind(port, addr);
}

void Socket::listen(int backlog)
{
    _impl.listen(backlog);
}

void Socket::accept(ISocket *nsock)
{
    Socket *csock;

    csock = dynamic_cast<Socket *>(nsock);
    _impl.accept(&csock->_impl);
}

void Socket::connect(int port, char *addr)
{
    _impl.connect(port, addr);
}

int Socket::send(const void *msg, size_t len)
{
    return _impl.send(msg, len);
}

int Socket::recv(void *buf, size_t len)
{
    return _impl.recv(buf, len);
}

void Socket::close()
{
    _impl.close();
}
